Comprehensive Guide
The Comprehensive Guide To Computercraft Simple LUA This Page is currently NOT finished. it will be uploaded when it is. Thank you for your patience: 64bitminecraft Creating and Editting Programs The Computercraft Mod for Minecraft is a mod that brings new programmable blocks into the Game, these can be used to display information or output redstone signals.? Computers come with some default programs, but to make more complex programs, or programs for a specific purpose, you will need to program them yourselves. to create a new program, or edit an existing one type edit name where name is the name you want to give the program. Now you are ready to make your first program. Basics of Coding All of the programs in ComputerCraft revolve around using commands such as: print("") write("") rs.setOutput("side", boolean) The print("") command prints the text between the speech marks on the screen and moves to the next line when it's done so. For example,? print("Hello world!") print("Hello world!") will display the following on your screen. Hello world! Hello world! The write command prints the text between the speech marks on the screen WITHOUT moving to the next line at the end. For example, write("Hello world!") write("Hello world!") will display the following on your screen. Hello world!Hello world! 'Strings' Anything between two quotation marks is a string. Strings are simply lines of characters that the computer will use literally. Ex: "Unicorns", "123456", "Hello world!". 'Integers/Numerical values' Integers are any numbers that aren't a string. The main difference being that Integers can have mathematical attributes applied to them (Such as a number being greater than another number, or basic arithmetic functions) Ex: 2, 5.6, -18000. Note: "1" is NOT the same thing as 1. "1" is a string, where 1 is an integer. Variables ? ? You can think of variables as buckets that hold information. When you need to store some information, you throw it in a bucket. And when you want to store different information in the bucket, it's easy to dump out the old information, and put in brand new information. Variables are defined in programs like this: (Note: The < and > are to denote groupings. Don't include them in the actual code.) = Variables can be named single letters, words, and they can include letters and most symbols. Generally, variables are equal to strings and integers, but they can also reference other variables. x = 1 y = x Hello = "World!" z = "Unicorns" You can use them in commands like below: print(x.."This is a string!") print(z..y..x) print(y) write(Hello) When using them in commands like this, note the absence of quotation marks around the variables. This denotes these characters as variables instead of strings.? Also, notice that when linking variables and strings, or when variables are linked to other variables in a print/write command, it is necessary to add a ".." in between them. User Input ? Now, by itself, the print command would be a nice way to make a digital book. But, for more interesting and complex programs, it becomes necessary for the user to input certain information into the program.? 'io.read()' name = io.read() In this code, the variable "name" is equal to "io.read()". io.read() prompts the user to type in some sort of information, and stores this information as a string equal to the variable. In this case, if I input "Ryan" when it asks me to, the variable "name" will be set equal to "Ryan", and whenever it is referenced, it will continue to equal "Ryan" until it's changed. 'Events' In much the same way as io.read(), the command os.pullEvent() allows for user input, and is stored as a variable, or multiple variables (depending on what event is triggered). Click here for more information on events. Category:Lua